//****************************************************************************************
//
// Header file for conversion routines between managed and unmanaged code
//
//****************************************************************************************

#pragma once

// include the Checkers Board Win32 runtime
#include "..\CheckersBoardWin32\Threading.h"

namespace CheckersBoardEngine {

	using namespace System;

	 // Move Computing Model Conversion
	////////////////////////////////////////////////////////////////////

	// color of side to move
	public enum class eColor
	{ White, Black };

	// figure type
	public enum class eFigure
	{ WhiteMan, BlackMan, WhiteKing, BlackKing, Nothing };

	// move configuration container class
	public ref class CBGameRecord
	{
	public:
		array<eFigure>^ Board;
		eColor SideToMove;
		double ComputingTime;
	};

	// board coordinates
	public ref class Coordinates
	{
	public:
		int x;
		int y;
	};

	public ref class ComputedMove
	{
	public:
		int jumps;
		eFigure newPiece, oldPiece;
		Coordinates^ from;
		Coordinates^ to;
		array<Coordinates^>^ path;
		array<Coordinates^>^ del;
		array<eFigure>^ delpieces;
	};


	// color conversion
	int ConvertColor(eColor clr);

	// figure conversion
	int ConvertFigure(eFigure figure);
	eFigure ConvertFigure(int figure);

	// pre-calculation game situation conversion
	void ConvertGameRecord(CBThreadParams* pParams, CBGameRecord^ gameRec);

	// converts coordinates
	Coordinates^ ConvertCoor(coor* c) ;

	// converts computed move
	ComputedMove^ ConvertMove(CBmove* m);

	 // Engine Options Model Conversion
	////////////////////////////////////////////////////////////////////////

	// engine options flags
	public ref class FEngineOptions
	{
	public:
		static int HASH_SIZE = 1;
		static int EGTB_SIZE = 2;
		static int BOOK = 4;
		static int ALL_SCORES = 8;
	};

	public ref class FEngineMoreOptions
	{
		static int MAX_DB_PIECES = 1;
		static int WDL_DIR = 2;
		static int MTC_DIR = 4;
		static int BOOK_FILE = 8;
		static int ENABLE_WDL = 16;
		static int ENABLE_MTC = 32;
		static int SEARCH_THREADS = 64;
	};

	// engine options
	public ref class EngineOptions
	{
	public:
		unsigned int flags;
		int db_MB;				// EGTB mem
		int hash_MB;			// hash mem
		int book;				// opening book
		int allscores;			// 
	};

	public ref class EngineMoreOptions
	{
	public:
		unsigned int flags;
		int max_dbpieces;			/* limits the maximum number of pieces to use in egdb init/lookups. */
		int wld_egdb_enable;
		String^ wld_directory;
		int mtc_egdb_enable;
		String^ mtc_directory;
		String^ book_filename;
		int search_threads;
	};


	EngineOptions^ ConvertEngineOptions(ENGINE_OPTIONS *optIn);
	ENGINE_OPTIONS* ConvertEngineOptions(EngineOptions^ optIn);
	EngineMoreOptions^ ConvertEngineOptions(MORE_ENGINE_OPTIONS *optIn);
	MORE_ENGINE_OPTIONS* ConvertEngineOptions(EngineMoreOptions^ optIn);
}
